function [arrivalRates] = getArrivalRates(indivConfigs, popAtRisk, paramsParts, XbetaFixed, Xdynamic_staticInputs, installedBases, tt)
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	% This function computes the instantaneous rate of arrival of providerAdoptions, providerExits and consumerAdoptions,
	% when the day (or period...) is tt and the installed bases are installedBases.
	%
	%   - XbetaFixed is sums up the utility parts that do not vary at the (t-k) level (hence will not change
	%   as a function of installedBases).
	%
	%  - Xdynamic_staticInputs contains the data parts at the (t-k) level (variables that do not depend on installedBases).
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	%%%%% Inputs:
	% indivConfigs:							object
	%	.consumerAdoptions:						object (as obtained by calling getConfig_consumerAdoptions)
	%	.providerAdoptions:						object (as obtained by calling getConfig_providerAdoptions)
	%	.providerExits:							object (as obtained by calling getConfig_providerExits)
	% popAtRisk:							object:
	%	.consumerAdoptions:						K x 1
	%	.providerAdoptions:						K x 1
	%	.providerExits:							K x 1
	%
	% paramsParts:							object:
	%	.consumerAdoptions:						cell(NumParts,1)
	%	.providerAdoptions:						cell(NumParts,1)
	%	.providerExits:							cell(NumParts,1)
	%
	% XbetaFixed:							object:
	%	.consumerAdoptions:						K1 x K2 x T
	%	.providerAdoptions:						K x T
	%	.providerExits:							K x T
	%
	% Xdynamic_staticInputs:				object:
	%	.consumerAdoptions:						object
	%		.Xparts_static:							cell(NumXparts,1)
	%			{2}:									object
	%				.X:										K1 x NumXstatic x T
	%				.X_FEs:									K1 x NumX_FEs x T
	%				.NumX_FE_vals:							1 x NumX_FEs
	%			{3}:									object
	%				.X:										K2 x NumXstatic x T
	%				.X_FEs:									K2 x NumX_FEs x T
	%				.NumX_FE_vals:							1 x NumX_FEs
	%		.extraArgs:							cell
	%			{1}:								K x T
	%	.providerAdoptions:						object
	%		.Xparts_static:							cell(NumXparts,1)
	%			{1}:									object
	%				.X:										K x NumXstatic x T
	%				.X_FEs:									K x NumX_FEs x T
	%				.NumX_FE_vals:							1 x NumX_FEs
	%		.extraArgs:							cell
	%			{1}:								K x T
	%	.providerExits:							object
	%		.Xparts_static:							cell(NumXparts,1)
	%			{1}:									object
	%				.X:										K x NumXstatic x T
	%				.X_FEs:									K x NumX_FEs x T
	%				.NumX_FE_vals:							1 x NumX_FEs
	%		.extraArgs:							cell
	%			{1}:								K x T
	%
	% installedBases:						object
	% 	.laggedConsumersOrig:						K x 1
	% 	.laggedConsumersDest:						K x 1
	% 	.laggedProviders:							K x 1
	% tt:									integer between 1 and T
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	%%%%% Outputs:
	% arrivalRates:				object
	%	.providerAdoptions:			K x 1
	%	.providerExits:				K x 1
	%	.consumerAdoptions:			K x 1
	%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	
	%%%%% providerAdoptions
	% Put together Xdynamic_staticInputs_tt
	Xparts_static = Xdynamic_staticInputs.providerAdoptions.Xparts_static;
	Xparts_static_tt{1}.X            = Xparts_static{1}.X(:,:,tt); % K x NumXstatic
	Xparts_static_tt{1}.X_FEs        = Xparts_static{1}.X_FEs(:,:,tt); % K x NumX_FEs
	Xparts_static_tt{1}.NumX_FE_vals = Xparts_static{1}.NumX_FE_vals; % 1 x NumX_FEs
	Xdynamic_staticInputs_tt.Xparts_static = Xparts_static_tt;	
	
	extraArgs = Xdynamic_staticInputs.providerAdoptions.extraArgs;
	if ~isempty(extraArgs)
		extraArgs1 = extraArgs{1}(:,tt); % K x 1
		Xdynamic_staticInputs_tt.extraArgs{1} = extraArgs1;
	end
	
	% Compute Xparts_dynamic_tt
	Xparts_dynamic_tt = make_Xdynamic_providerAdoptions(indivConfigs.providerAdoptions, Xdynamic_staticInputs_tt, installedBases, false);
	
	% Clean up
	clear Xparts_static Xparts_static_tt extraArgs Xdynamic_staticInputs_tt;
	
	% Compute V (sum up part that depends on installed base and part that does not)
	Xbeta1_tt = compute_Xbeta_part(Xparts_dynamic_tt{1}, paramsParts.providerAdoptions{1}); % K x 1
	V_tt = XbetaFixed.providerAdoptions(:,tt) + Xbeta1_tt; % K x 1
	
	% Compute logLambdaOffset (depends on pops at risk)
	logLambdaOffset_tt = log(popAtRisk.providerAdoptions); % K x 1
	
	% Draw Y
	logLambda_tt  = logLambdaOffset_tt + V_tt; % K x 1
	arrivalRates.providerAdoptions     = exp(logLambda_tt); % K x 1
	
	clear Xbeta1_tt V_tt logLambdaOffset_tt logLambda_tt;

	%%%%% providerExits
	% Put together Xdynamic_staticInputs_tt
	Xparts_static = Xdynamic_staticInputs.providerExits.Xparts_static;
	Xparts_static_tt{1}.X            = Xparts_static{1}.X(:,:,tt); % K x NumXstatic
	Xparts_static_tt{1}.X_FEs        = Xparts_static{1}.X_FEs(:,:,tt); % K x NumX_FEs
	Xparts_static_tt{1}.NumX_FE_vals = Xparts_static{1}.NumX_FE_vals; % 1 x NumX_FEs
	Xdynamic_staticInputs_tt.Xparts_static = Xparts_static_tt;
	
	extraArgs = Xdynamic_staticInputs.providerExits.extraArgs;
	if ~isempty(extraArgs)
		extraArgs1 = extraArgs{1}(:,tt); % K x 1
		Xdynamic_staticInputs_tt.extraArgs{1} = extraArgs1;
	end
	
	% Compute Xparts_dynamic_tt
	Xparts_dynamic_tt = make_Xdynamic_providerExits(indivConfigs.providerExits, Xdynamic_staticInputs_tt, installedBases, false);
	
	% Clean up
	clear Xparts_static Xparts_static_tt extraArgs Xdynamic_staticInputs_tt;
	
	% Compute V (sum up part that depends on installed base and part that does not)
	Xbeta1_tt = compute_Xbeta_part(Xparts_dynamic_tt{1}, paramsParts.providerExits{1}); % K x 1
	V_tt = XbetaFixed.providerExits(:,tt) + Xbeta1_tt; % K x 1
	
	% Compute logLambdaOffset (depends on pops at risk)
	logLambdaOffset_tt = log(popAtRisk.providerExits); % K x 1
	
	% Draw Y
	logLambda_tt  = logLambdaOffset_tt + V_tt; % K x 1
	arrivalRates.providerExits     = exp(logLambda_tt); % K x 1
	
	clear Xbeta1_tt V_tt logLambdaOffset_tt logLambda_tt;
	
	
	%%%%% consumerAdoptions
	% Put together Xdynamic_staticInputs_tt
	Xparts_static = Xdynamic_staticInputs.consumerAdoptions.Xparts_static;
	Xparts_static_tt{2}.X            = Xparts_static{2}.X(:,:,tt);     % K1 x NumXstatic
	Xparts_static_tt{2}.X_FEs        = Xparts_static{2}.X_FEs(:,:,tt); % K1 x NumX_FEs
	Xparts_static_tt{2}.NumX_FE_vals = Xparts_static{2}.NumX_FE_vals;  % 1 x NumX_FEs
	
	Xparts_static_tt{3}.X            = Xparts_static{3}.X(:,:,tt);     % K2 x NumXstatic
	Xparts_static_tt{3}.X_FEs        = Xparts_static{3}.X_FEs(:,:,tt); % K2 x NumX_FEs
	Xparts_static_tt{3}.NumX_FE_vals = Xparts_static{3}.NumX_FE_vals;  % 1 x NumX_FEs
	
	Xdynamic_staticInputs_tt.Xparts_static = Xparts_static_tt;
	
	extraArgs = Xdynamic_staticInputs.consumerAdoptions.extraArgs;
	if ~isempty(extraArgs)
		extraArgs1 = extraArgs{1}(:,tt); % K x 1
		Xdynamic_staticInputs_tt.extraArgs{1} = extraArgs1;
	end
	
	% Compute Xparts_dynamic_tt
	Xparts_dynamic_tt = make_Xdynamic_consumerAdoptions(indivConfigs.consumerAdoptions, Xdynamic_staticInputs_tt, installedBases, false);
	
	% Clean up
	clear Xparts_static Xparts_static_tt extraArgs Xdynamic_staticInputs_tt;
	
	% Compute V (sum up part that depends on installed base and part that does not)
	Xbeta2_tt = compute_Xbeta_part(Xparts_dynamic_tt{2}, paramsParts.consumerAdoptions{2}); % K1 x 1
	Xbeta3_tt = compute_Xbeta_part(Xparts_dynamic_tt{3}, paramsParts.consumerAdoptions{3}); % K2 x 1		
	% Trick: Put a high penalty on Xbeta3_tt in case where there is no provider, so that the corresponing lambda will be effectively zero.
	Xbeta3_tt = Xbeta3_tt -1e8*(installedBases.laggedProviders <= 0); 
	
	K1 = size(Xbeta2_tt,1);
	K2 = size(Xbeta3_tt,1);
	V_tt = reshape(XbetaFixed.consumerAdoptions(:,:,tt), [K1 K2]) + Xbeta2_tt + Xbeta3_tt'; % K1 x K2
	
	% Compute logLambdaOffset (depends on pops at risk)
	logLambdaOffset_tt = log(popAtRisk.consumerAdoptions); % K1 x 1
	
	% Draw Y
	logLambda_tt  = logLambdaOffset_tt + V_tt; % K1 x K2
	arrivalRates.consumerAdoptions     = exp(logLambda_tt); % K1 x K2
end
